home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Atari Compendium
/
The Atari Compendium (Toad Computers) (1994).iso
/
files
/
umich
/
sound
/
players
/
noisetra.s
< prev
next >
Wrap
Text File
|
1992-10-29
|
27KB
|
1,615 lines
*************************************************
* This NoiseTracker source is made by: *
* Lars-Åke Berg *
* Email adress:d0berg@dtek.chalmers.se *
* It is PublicDomain *
* If you want to get in contact with me *
* use my email adress or write to *
* Lars-Åke Berg *
* Volratamsgatan 6-9320 *
* 412 60 Göteborg *
* Sweden *
* or phone 046-(0)31-163123 *
*************************************************
* Thanx to M.K for the sorce.(from the Amiga) *
*************************************************
* This player uses NoiseTracker modules from *
* the amiga (not SoundTracker and ProTracker). *
* To start, it,do like this. *
* 1. Assamble it in (Seka). *
* 2. Chose playing frek by puting 0,1 or 2(.l) *
* in hz (label). *
* 3. jump to start. *
* 4. to stop playing jump to back. *
* 3 diffrent playing frek. are included. *
* The flag hz(.l) stands for *
* 0(.l)=6.25 kHz 1(.l)=12.5 kHz 2(.l)=25.0 kHz *
* don't forget to do initmusic and initdma *
* after changing playing frek. *
*************************************************
moduldta=$80000
start:
bsr.L mod_init
bsr.l initmusic
bsr.l initdma
move.w #$2700,sr
move.l $70,oldvbl
move.l #vbl,$70
move.w #$2300,sr
rts
back:
move.w #$2700,sr
move.l oldvbl,$70
; move.w #$-1,$ff8240
move.w #$2300,sr
rts
oldvbl: dc.l 0
vbl:
movem.l a0-a6/d0-d7,-(sp)
; move.w #$000,$ff8240
bsr.L playmod
move.w #$fff,$ff8240
bsr.l Atari_rutin
; move.w #$-1,$ff8240
bsr.s levelstaplar
movem.l (sp)+,a0-a6/d0-d7
rte
***********************************************
;show rutiner
***********************************************
levelstaplar:
lea voice1+6,a1
lea old_voltab,a2
move.w (a1),d0 ;level ch 0
move.w 28(a1),d1;level ch 1
move.w 56(a1),d2;level ch 2
move.w 84(a1),d3;level ch 3
and.w #$7f,d0
and.w #$7f,d1
and.w #$7f,d2
and.w #$7f,d3
lsr.w #1,d0 ;skala ner 2 ggr.
lsr.w #1,d1
lsr.w #1,d2
lsr.w #1,d3
lea $f8002+[160*90],a0
bsr.s vol_before
bsr.s channel
lea $f800a+[160*90],a0
move.w d1,d0
bsr.s vol_before
bsr.s channel
lea $f8012+[160*90],a0
move.w d2,d0
bsr.s vol_before
bsr.s channel
lea $f801a+[160*90],a0
move.w d3,d0
bsr.s vol_before
bsr.s channel
rts
vol_before:
cmp.w #$40,d0
ble.s no_error_vol
moveq #$40,d0
no_error_vol:
move.w (a2),d5
cmp.w d5,d0
blo.s minska_st
move.w d0,(a2)+
rts
minska_st:
subq.w #1,d5
bpl.s minska_st2
moveq #0,d5
minska_st2:
move.w d5,(a2)+
move.w d5,d0
rts
channel:
lea stapel,a1
lsl.w #1,d0
and.l #$00fe ,d0
add.l d0,a1
moveq #31,d4
lpstap:
move.w (a1)+,(a0)
lea 160(a0),a0
dbf d4,lpstap
rts
old_voltab:
dc.w 0,0,0,0
stapel:
dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.w 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
dc.w -1,-1,-1,-1,-1,-1,-1,-1
dc.w -1,-1,-1,-1,-1,-1,-1,-1
dc.w -1,-1,-1,-1,-1,-1,-1,-1
dc.w -1,-1,-1,-1,-1,-1,-1,-1
************************************************
mod_init:
;spara pekare till smp data.
lea moduldta,a0
lea spl_dta_starts,a1
lea 42(a0),a0
moveq #31,d0 ;max 31 sampels.
moveq #$1e,d1
init_lp:
move.l a0,(a1)+
add.l d1,a0
dbf d0,init_lp
;leta reda pa hogsta pattern nr. ->d2
lea moduldta,a0
lea 952(a0),a0
moveq #127,d0 ;max 128
moveq #0,d1
moveq #0,d2
init_lp2:
move.b (a0)+,d1
cmp.b d2,d1
ble.s init_lp3
move.w d1,d2
init_lp3:
dbf d0,init_lp2
addq.l #1,d2 ;step to spl.
;find samples starts
lea moduldta,a0
lea 1084(a0),a0 ;pattern starts
lea spl_starts,a1
lea spl_dta_starts,a2
lsl.l #8,d2 ;mulu 1024
lsl.l #2,d2 ;step to first spl.
add.l d2,a0 ;pointer spl.
moveq #31,d1
init_lp4:
moveq #0,d0
move.l a0,(a1)+
move.l (a2)+,a3
move.w (a3),d0 ;len in words
lsl.w #1,d0 ;in bytes
add.l d0,a0
dbf d1,init_lp4
;set volym =0
lea voice1,a0
moveq #0,d0
move.w d0,6(a0)
move.w d0,28+6(a0)
move.w d0,56+6(a0)
move.w d0,84+6(a0)
move.b d0,songpos
move.b d0,counter
move.w d0,patternpos
move.b #6,songspeed
rts
;init data.
spl_dta_starts: blk.l 32,0
spl_starts: blk.l 32,0
songpos: dc.b 0
counter: dc.b 0
patternpos: dc.w 0
songspeed: dc.b 0
mod_break: dc.b 0
even
playmod:
lea moduldta,a0
add.b #1,counter
move.b counter,d0
cmp.b songspeed,d0
blo.L no_new
new_voice:
moveq #0,d0
moveq #0,d1
lea 1084(a0),a1 ;first pattern pek
move.b d0,counter
move.b songpos,d0
add.l #950,a0
move.b 2(a0,d0.w),d0
move.w patternpos,d1
lsl.l #8,d0 ;find right pattern offset.
lsl.l #2,d0
lea spl_starts,a2
lea spl_dta_starts,a6
lea voice1,a4
bsr.s playvoice
addq.w #4,d1
lea voice2,a4
bsr.s playvoice
addq.w #4,d1
lea voice3,a4
bsr.s playvoice
addq.w #4,d1
lea voice4,a4
bsr.s playvoice
addq.w #4,d1
move.w d1,patternpos
cmp.w #1024,d1
bne.s not_end_pattern
end_pattern:
move.w #0,patternpos
clr.b mod_break
add.b #1,songpos
move.b songpos,d0
cmp.b (a0),d0
bne.s not_end_song
end_song:
move.b #0,songpos
move.w #0,patternpos
not_end_pattern:
not_end_song:
tst.b mod_break
bne.s end_pattern
rts
playvoice:
lea 0(a1,d0.l),a3 ;pattern pek
add.l d1,a3 ;pattern pos
move.l (a3),18(a4) ;lagra ton dta.
moveq #0,d2
moveq #0,d3
move.w 18(a4),d2
move.w 18+2(a4),d3
and.w #$f000,d2
and.w #$f000,d3
lsr.w #4,d3
or.w d3,d2
lsr.w #8,d2
tst.w d2
beq.L old_instr
sub.w #1,d2
lsl.w #2,d2
move.l 0(a2,d2.w),a5 ;spl start
move.l a5,(a4) ;to voicedta
move.l a5,d3 ;copy spl start
move.l 0(a6,d2.w),a5 ;spl dta pek
move.w (a5),d2
lsl.w #1,d2 ;len in bytes
neg.w d2
sub.l d2,(a4) ;andra spl start
move.w d2,4(a4) ;to voicedta
move.w 2(a5),d2
and.w #$007f,d2 ;volyme (mask bort fine tune)
cmp.w #$40,d2
ble.s volmask
moveq #$40,d2
volmask:
move.w d2,6(a4) ;volym
moveq #0,d2
move.w 4(a5),d2 ;rep point
beq.s no_loop ;no rep from beginning
lsl.w #1,d2 ;to bytes.
add.l d3,d2
move.l d2,8(a4) ;rep start
moveq #0,d4
move.w 6(a5),d4 ;rel len
lsl.w #1,d4 ;rep len in bytes
neg.w d4
sub.l d4,8(a4) ;rep start.
move.w d4,12(a4) ;rep dta pek. (len)
bra.s looping
no_loop:
move.l d3,8(a4)
moveq #0,d3
move.w 6(a5),d3
sub.w #1,d3 ;kompensation
lsl.w #1,d3
neg.w d3
sub.l d3,8(a4)
move.w d3,12(a4)
looping:
move.w #0,16(a4)
old_instr:
move.w 18(a4),d2
and.w #$0fff,d2 ;note period
beq.L mod_command2
tst.w 4(a4) ;tst spl len
beq.s stopsound
move.b 18+2(a4),d3 ;effect command
and.b #$0f,d3
cmp.b #5,d3
beq.s set_port
cmp.b #3,d3
beq.s set_port
move.w d2,14(a4) ;to voicedta
clr.b 27(a4)
bra.L mod_command2
stopsound:
move.w #0,6(a4)
bra.L mod_command2
no_new:
lea voice1,a4
bsr.L mod_command
lea voice2,a4
bsr.L mod_command
lea voice3,a4
bsr.L mod_command
lea voice4,a4
bsr.L mod_command
rts
set_port:
move.w 18(a4),d2 ;period
and.w #$0fff,d2
move.w d2,22(a4) ;new period?
move.w 14(a4),d3 ;old note period
clr.b 24(a4)
cmp.w d3,d2
beq.s mod_clrport
bge.L mod_command2
move.b #1,24(a4) ;set flag
bra.L mod_command2
mod_clrport:
clr.w 22(a4)
rts
mod_port:
moveq #0,d3
move.b 18+3(a4),d2
beq.s mod_port2
move.b d2,25(a4)
move.b d3,18+3(a4)
mod_port2:
tst.w 22(a4)
beq.s mod_rts
move.b 25(a4),d3
tst.b 24(a4)
bne.s mod_sub
add.w d3,14(a4)
move.w 22(a4),d3
cmp.w 14(a4),d3
bgt.s mod_portok
move.w 22(a4),14(a4)
clr.w 22(a4)
mod_portok:
mod_rts:
rts
mod_sub:
sub.w d3,14(a4)
move.w 22(a4),d3
cmp.w 14(a4),d3
blt.s mod_portok
move.w 22(a4),14(a4)
clr.w 22(a4)
rts
mod_sin:
dc.b $00,$18,$31,$4a,$61,$78,$8d,$a1
dc.b $b4,$c5,$d4,$e0,$eb,$f4,$fa,$fd
dc.b $ff,$fd,$fa,$f4,$eb,$e0,$d4,$c5
dc.b $b4,$a1,$8d,$78,$61,$4a,$31,$18
mod_vib:
move.b 18+3(a4),d3
beq.s mod_vib2
move.b d3,26(a4)
mod_vib2:
move.b 27(a4),d3
lsr.w #2,d3
and.w #$1f,d3
moveq #0,d2
lea mod_sin,a3
move.b 0(a3,d3.w),d2
move.b 26(a4),d3
and.w #$0f,d3
mulu d3,d2
lsr.w #7,d2
move.w 14(a4),d3
tst.b 27(a4)
bmi.s mod_vibsub
add.w d2,d3
bra.s mod_vib3
m